<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="kityformula/assets/styles/base.css">
    <link rel="stylesheet" href="kityformula/assets/styles/ui.css">
    <link rel="stylesheet" href="kityformula/assets/styles/scrollbar.css">
    <style>
        html, body {padding: 0;margin: 0;}
        .kf-editor {width: 798px;height: 440px;}
        #loading {height: 32px;width: 340px;line-height: 32px;position: absolute;top: 42%;left: 50%;margin-left: -170px;font-family: arial,"Hiragino Sans GB","Microsoft YaHei";}
        #loading img {position: absolute;}
        #loading p {display: block;position: absolute;left: 40px;top: 0;margin: 0;}
    </style>
</head>
<body>
<div id="kfEditorContainer" class="kf-editor">
    <div id="tips" class="tips">
        对不起! kityFormula此版本仅支持IE9及以上版本的浏览器，请升级您的浏览，祝你使用愉快！
    </div>
</div>

<script src="kityformula/js/jquery-1.11.0.min.js"></script>
<script src="kityformula/js/kitygraph.all.js"></script>
<script src="kityformula/js/kity-formula-render.all.js"></script>
<script src="kityformula/js/kity-formula-parser.all.min.js"></script>
<script src="kityformula/js/kityformula-editor.all.min.js"></script>
<script src="kityformula/js/editor-control.js"></script>
<script>
    var _KFEditor = null;
    jQuery( function ($) {
        var hash = location.hash;
        if(hash){
            var mydomain = hash.replace(/#/g,'');
            document.domain = mydomain;
        }
        if ( document.body.addEventListener ) {

            $( "#tips").html('<div id="loading"><img src="kityformula/loading.gif" alt="loading" /><p>正在加载，请耐心等待...</p></div>' );

            var factory = kf.EditorFactory.create( $( "#kfEditorContainer" )[ 0 ], {
                render: {
                    fontsize: 40
                },
                resource: {
                    path: "./kityformula/resource/"
                }
            } );

            factory.ready( function ( KFEditor ) {

                $( "#tips").remove();

                // this指向kityformula

                this.execCommand( "render", "\\placeholder" );
                this.execCommand( "focus" );
                _KFEditor = KFEditor;
            } );

        } else {
            $( "#tips").css( {"color": "black", "padding": "10px"} );
        }
    });

    function getImageURL(callback) {
        if(_KFEditor!=null){
            _KFEditor.execCommand( "get.image.data", function ( data ) {
                if($.isFunction(callback)){
                    callback(data.img);
                }
            });
        }
    }
</script>
</body>
</html>